package com.how2java.controller;


import com.how2java.model.saasUser;
import com.how2java.service.impl.UserImpl;
import com.how2java.util.ViewUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

@Controller
public class indexController {
    @Autowired
    private UserImpl user;

    @RequestMapping("/users")
    public ModelAndView users(HttpServletRequest request, HttpServletResponse response) throws Exception {
        saasUser saasUser = user.selectByPrimaryKey(1L);

        ModelAndView mav = new ModelAndView();
        mav.setViewName("user");
        mav.addObject("saasUser", saasUser);
        return mav;

//        Map<String, Object> model = new HashMap<>();
//        model.put("pageTitle", "我是标题");
//        model.put("user", user);
//        return ViewUtil.render(request, model, "WEB-INF/velocity/user.vm");
    }

}
